﻿// Decompiled with JetBrains decompiler
// Type: NetworkMessages.FromServer.SetRoundMVP
// Assembly: TaleWorlds.MountAndBlade, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: D5209D1B-76B5-47CA-B957-255CD4B2CE6B
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.MountAndBlade.dll

using TaleWorlds.MountAndBlade;
using TaleWorlds.MountAndBlade.Network.Messages;

#nullable disable
namespace NetworkMessages.FromServer
{
  [DefineGameNetworkMessageType(GameNetworkMessageSendType.FromServer)]
  public sealed class SetRoundMVP : GameNetworkMessage
  {
    public int MVPCount;

    public NetworkCommunicator MVPPeer { get; private set; }

    public SetRoundMVP(NetworkCommunicator mvpPeer, int mvpCount)
    {
      this.MVPPeer = mvpPeer;
      this.MVPCount = mvpCount;
    }

    public SetRoundMVP()
    {
    }

    protected override bool OnRead()
    {
      bool bufferReadValid = true;
      this.MVPPeer = GameNetworkMessage.ReadNetworkPeerReferenceFromPacket(ref bufferReadValid);
      this.MVPCount = GameNetworkMessage.ReadIntFromPacket(CompressionBasic.RoundTotalCompressionInfo, ref bufferReadValid);
      return bufferReadValid;
    }

    protected override void OnWrite()
    {
      GameNetworkMessage.WriteNetworkPeerReferenceToPacket(this.MVPPeer);
      GameNetworkMessage.WriteIntToPacket(this.MVPCount, CompressionBasic.RoundTotalCompressionInfo);
    }

    protected override MultiplayerMessageFilter OnGetLogFilter()
    {
      return MultiplayerMessageFilter.Mission | MultiplayerMessageFilter.GameMode;
    }

    protected override string OnGetLogFormat() => "MVP selected as: " + this.MVPPeer.UserName + ".";
  }
}
